package cn.com.inossem.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import cn.com.inossem.base.RequestActivity;
import cn.com.inossem.utils.ActivityStackControlUtil;

import com.foxykeep.datadroid.requestmanager.Request;

/**
 * 
 * 高级搜索 Kj4UAR13GLXInoMzQgLDINYV
 * <p>
 * detailed comment
 * 
 * @author szc 2015-8-24
 * @see
 * @since 1.0
 */
public class AdvancedSearchActivity extends RequestActivity {

	RelativeLayout RLayout, RLayout1, RLayout2, RLayout3, RLayout4, RLayout5;
	TextView zhouqi, hangye, address, xingzhi, model, gangwei, sousuo,
			delcontent;
	ImageView back;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// setContentView(R.layout.jobsdetails_layout);
		initView();

	}

	@Override
	public void onDestroy() {
		ActivityStackControlUtil.remove(this);
		super.onDestroy();
	}

	private void initView() {
		RLayout = (RelativeLayout) this.findViewById(R.id.RLayout);
		RLayout.setOnClickListener(this);
		RLayout1 = (RelativeLayout) this.findViewById(R.id.RLayout1);
		RLayout1.setOnClickListener(this);
		RLayout2 = (RelativeLayout) this.findViewById(R.id.RLayout2);
		RLayout2.setOnClickListener(this);
		RLayout3 = (RelativeLayout) this.findViewById(R.id.RLayout3);
		RLayout3.setOnClickListener(this);
		RLayout4 = (RelativeLayout) this.findViewById(R.id.RLayout4);
		RLayout4.setOnClickListener(this);
		RLayout5 = (RelativeLayout) this.findViewById(R.id.RLayout5);
		RLayout5.setOnClickListener(this);

		zhouqi = (TextView) this.findViewById(R.id.zhouqi);
		hangye = (TextView) this.findViewById(R.id.hangye);
		address = (TextView) this.findViewById(R.id.address);
		xingzhi = (TextView) this.findViewById(R.id.xingzhi);
		model = (TextView) this.findViewById(R.id.model);
		gangwei = (TextView) this.findViewById(R.id.gangwei);
		sousuo = (TextView) this.findViewById(R.id.sousuo);
		sousuo.setOnClickListener(this);
		delcontent = (TextView) this.findViewById(R.id.delcontent);
		delcontent.setOnClickListener(this);

		back = (ImageView) this.findViewById(R.id.back);
		back.setOnClickListener(this);

	}

	@Override
	public Request getInitialRequest() {
		return null;

	}

	@Override
	public void onRequestSucess(Request request, Bundle bundle) {
	}

	@Override
	public void onRequestError(int exceptionType) {

	}

	public int getContentViewId() {
		return R.layout.advancedsearch_layout;

	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		Intent intent = null;
		switch (v.getId()) {
		case R.id.back:
			finish();
			break;
		case R.id.RLayout:
			intent = new Intent(this, RetrieveItemActivity.class);
			intent.putExtra("type", 2);
			startActivityForResult(intent, 0);
			break;
		case R.id.RLayout1:
			intent = new Intent(this, RetrieveItemActivity.class);
			intent.putExtra("type", 1);
			startActivityForResult(intent, 0);
			break;
		case R.id.RLayout2:
			intent = new Intent(this, CityActivity.class);
			intent.putExtra("type", 0);
			startActivityForResult(intent, 0);
			break;
		case R.id.RLayout3:
			intent = new Intent(this, RetrieveItemActivity.class);
			intent.putExtra("type", 5);
			startActivityForResult(intent, 0);
			break;
		case R.id.RLayout4:
			intent = new Intent(this, RetrieveItemActivity.class);
			intent.putExtra("type", 3);
			startActivityForResult(intent, 0);
			break;
		case R.id.RLayout5:
			intent = new Intent(this, RetrieveItemActivity.class);
			intent.putExtra("type", 4);
			startActivityForResult(intent, 0);
			break;

		case R.id.sousuo:
			intent = new Intent();
			intent.putExtra("projectCycle", projectCyclestr);
			intent.putExtra("projectIndustry", projectIndustrystr);
			intent.putExtra("model", modelstr);
			intent.putExtra("station", stationstr);
			intent.putExtra("projectAddress", projectAddressstr);
			intent.putExtra("projectNature", projectNaturestr);
			setResult(1, intent);
			finish();
			break;
		case R.id.delcontent:
			projectCyclestr = "";
			projectIndustrystr = "";
			modelstr = "";
			stationstr = "";
			projectAddressstr = "";
			projectNaturestr = "";

			zhouqi.setText("全部");
			hangye.setText("全部");
			model.setText("全部");
			gangwei.setText("全部");
			xingzhi.setText("全部");
			address.setText("全部");
			break;
		default:
			break;
		}
	}

	String projectCyclestr = "";
	String projectIndustrystr = "";
	String modelstr = "";
	String stationstr = "";
	String projectAddressstr = "";
	String projectNaturestr = "";

	protected void onActivityResult(int requestCode, int resultCode,
			Intent intent) {
		if (intent == null)
			return;
		String name = intent.getStringExtra("name");
		String num = intent.getStringExtra("num");
		String result = intent.getStringExtra("result");
		switch (resultCode) { // resultCode为回传的标记，我在B中回传的是RESULT_OK
		case 1:
			zhouqi.setText(name + num);
			projectCyclestr = result;
			break;
		case 2:
			hangye.setText(name + num);
			projectIndustrystr = result;
			break;
		case 3:
			model.setText(name + num);
			modelstr = result;
			break;
		case 4:
			gangwei.setText(name + num);
			stationstr = result;
			break;
		case 5:
			xingzhi.setText(name + num);
			projectNaturestr = result;
			break;
		case 6:
			address.setText(name + num);
			projectAddressstr = result;
			break;
		case 7:
			break;
		default:
			break;
		}
	}
}
